# from django.core.paginator import Paginator  # 注释掉Django分页器
from datetime import datetime
import dofile
from flask import Blueprint, request, render_template, jsonify, session, flash, redirect
from werkzeug.utils import secure_filename

import verfy
from models import Homework, Uploadhomework, Teacher, Student,Copy
from collections import OrderedDict
from exts import db
import plagiaris_check as pc

bp = Blueprint("document", __name__, url_prefix="/document")


@bp.before_request
def before_request():
    """文档蓝图权限检查"""
    # 检查用户是否登录
    if session.get('is_login') != 'true':
        return redirect('/login')
    
    # 文档功能对所有登录用户开放
    user_role = session.get('role')
    if user_role not in ['teacher', 'student']:
        return jsonify({'error': '用户角色无效'}), 403

@bp.route("/")
def student_index():
    return render_template('document.html')